#!/usr/local/bin/perl
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use locale;
$query = new CGI;

$fullcat = $query->param('category');
$category = $query->param('category');
($category, $count, $detail) = split(/\-/, $category);
$category_file = "admin/cat_files/$category.txt";
$nav_file = "admin/cat_files/category.txt";
$numbItem = 7;	#number of Item display per page
$start = ($count - 1) * $numbItem;
$end = $count * $numbItem;
$numbLinks = 1;

%catDescription = (
			PAPER_LANTERNS => ["Shoji Decor's <strong>paper lanterns</strong> are made of <em>premium quality rice paper</em>,  which allow paper lantern creases to easily straighten, by simply misting with  water. We have a great selection of unique styles, large or small, and colors  of lanterns to compliment any setting. We also have <strong>round paper lanterns</strong> that have <em>even  ribbing</em>.<br />	Along with paper lanterns, Shoji also sells just the <a href=\"http://www.shojidecor.com/category/SHOJI_PAPERS\">shoji papers</a>, <a href=\"http://www.shojidecor.com/category/SHOJI_BLINDS\">shoji blinds</a>, <a href=\"http://www.shojidecor.com/category/PAPER_UMBRELLAS\">paper umbrellas</a>, and <a href=\"http://www.shojidecor.com/category/PAPER_PARASOL_SHADES\">paper parasol shades.</a>"],
			PARTY_LANTERNS => ["Our <strong>party lantern</strong> lights, as well as our <a href=\"http://www.shojidecor.com/category/FESTIVE_LANTERNS\">festive lanterns</a> and <a href=\"http://www.shojidecor.com/category/CENTERPIECE_LANTERNS\">centerpiece lanterns</a>, are great for parties on any occasion. We have a great  assortment of shapes, colors and sizes that are fun and <em>festive for indoor or outdoor</em>. We have a great sale going on for  our <strong>party lantern party light sets</strong>.  Not finding what you're looking for? We have a wide variety of <a href=\"http://www.shojidecor.com/category/PAPER_LANTERNS\">paper lanterns</a>, and for those of you looking for cordless, we have <a href=\"http://www.shojidecor.com/category/BATTERY_LANTERNS\">battery powered lanterns</a>.<br />	VOLUME  DISCOUNTS- We offer discounts to volume purchases. Please contact customer  service to obtain discounted rates. Toll-free 1-877-746-5438."],
			TABLE_LAMPS => ["Our table lamps are made of quality rice paper or fabric shades and various types of wood. We offer contemporary or traditional styles of table lamps that can beautifully illuminate any room or office."],
			FLOOR_LAMPS => ["Our artistically sculptured floor lamps are made of quality rice paper with a satin steel finished base. All the floor lamps have a step on and off switch. Most of our floor lamps are also available in a table lamp style that can beautifully compliment each other in any room or office."],
			HANGING_LAMPS => ["Shoji Decor Hanging Lamp collections includes complete electrical fitting."],
			SHOJI_BLINDS => ["Our shoji blinds are made of Pellon (cotton material) with wooden rails. We have a large variety of plain or colorful designs and sizes that suites your needs. Our shoji blinds can also be rolled up to a desirable length."],
			FESTIVE_LANTERNS => ["Add festive paper lanterns to your summer party fun, event or wedding. Our festive paper lanterns comes in different colors, shapes and printed designs."],
			LANTERN_CORD_KITS => ["All of our electrical socket cords are UL listed."],
			NYLON_LANTERNS => ["Durable lanterns made of quality nylon fabric."],
			PAPER_PARASOL_SHADES => ["Decorate your home or party with our latest Parasol Shades. Comes with wire clip to attach on any standard light bulb. May be use as hanging, wall mount or ceiling mount to an existing light fixture. "],
			CENTERPIECE_LANTERNS => ["Table centerpiece battery lanterns are hand made of quality rice paper with wired ribbings. Six bright-burst LED type bulbs nicely lit up the lantern centerpiece. Requires three AAA alkaline batteries that last for 22 hours. Solid wooden base is crafted with five pre-drilled holes for silk flowers, sprays or twigs(not included) decoration. Get creative for your wedding or party events.<div class=\"bulk-note\">VOLUME DISCOUNTS- We offer discounts to volume purchases.  Please contact customer service to obtain discounted rates. Toll-free 1-877-746-5438</div> "],
			BATTERY_LANTERNS => ["These LED battery operated paper lanterns are made of quality rice paper with tightly spaced wired ribs. Each lantern base includes six LED ULTRA-EFFICIENT or LED WARM-BRIGHT-BURST type bulbs. Amazingly bright that lasts over 22 to 36 hours with just one set of batteries. *Shojidecor.com exclusive"],
		);
%Title = (
			PAPER_LANTERNS => ["Wedding Paper Lanterns | Artistic shaped Paper Lanterns | Hanging Lantern Lights"],
			PARTY_LANTERNS => ["Paper Party Lanterns | Party Hanging Lanterns | Party Lantern Decorations"],
			TABLE_LAMPS => ["Paper lantern Table lamps"],
			FLOOR_LAMPS => ["Paper Lantern Floor lamps"],
			HANGING_LAMPS => ["Hanging lamps"],
			SHOJI_BLINDS => ["Shoji blinds"],
			SHOJI_PAPERS => ["Shoji papers"],
			PAPER_PARASOL_SHADES => ["parasol lamp shades-Hanging, Ceiling and Wall mount"],
			PAPER_UMBRELLAS => ["Paper Parasols,Paper Umbrellas"],
			FESTIVE_LANTERNS => ["Festive paper lanterns"],
			VALUE_PACK_LANTERNS => ["Value pack discount paper lanterns"],
			BATTERY_LANTERNS => ["Battery lanterns"],
			NYLON_LANTERNS => ["Nylon Lanterns"],
			LANTERN_CORD_KITS => ["Lantern Cords and Battery Terminals"],
			CENTERPIECE_LANTERNS => [" Wedding Table Decorations, Table Centerpiece - Battery Operated Table Lanterns  "],
			Contact_Us => ["Contact Shoji Decor"],
			About_Us => ["About Shoji Decor"],
			Policies => ["Company Policies"]
		);

%MetaTags = (
			PAPER_LANTERNS => ["<META NAME=\"Title\" CONTENT=\"Large Paper Lantern | Paper Round Lanterns | Hanging Lantern Lights\"><meta name=\"Keywords\" CONTENT=\"Large Paper Lantern, Paper Round Lanterns, Hanging Lantern Lights\">\n<meta name=\"Description\" CONTENT=\"Shoji Decor specializes in Paper Lanterns that range from Large Paper Lanterns, to Paper Round Lanterns, to Hanging Lanterns with Lights.\">
			"],
			PARTY_LANTERNS => ["<META NAME=\"Title\" CONTENT=\"Paper Party Lantern | Party Lantern| Party Lantern Decorations\"><meta name=\"Keywords\" CONTENT=\"Paper Party Lantern, Party Lantern, Party Lantern Decorations\"> \n<meta name=\"Description\" CONTENT=\"Shoji Decor has a great selection of party lanterns. We have Jumbo even round light sets along with mini box and oval party lantern decorations.\">"],
			TABLE_LAMPS => ["<meta name=\"Keywords\" CONTENT=\"Paper table lamps, Japanese paper lamps, Table paper lamp lanterns\">\n<meta name=\"Description\" CONTENT=\"Sculptured design paper lanterns table lamps are handcrafted with bamboo or wired ribbing and high grade rice paper.\">"],
			FLOOR_LAMPS => ["<meta name=\"Keywords\" CONTENT=\"Paper floor lamps, Japanese paper lamps, Floor paper lamp lanterns\">\n<meta name=\"Description\" CONTENT=\"Sculptured design paper lanterns floor lamps, handcrafted with bamboo or wired ribbing and high grade rice paper.\">"],
			NYLON_LANTERNS => ["<meta name=\"Keywords\" CONTENT=\"Nylon lanterns, Nylon paper lanterns\"> \n<meta name=\"Description\" CONTENT=\"Durable Nylon lanterns provide the shimmery designs are great for outdoor and indoor. Illuminate the Nylon lanterns for your party, wedding, or use for homes and restaurants\">"],
			HANGING_LAMPS => [""],
			SHOJI_BLINDS => [""],
			CENTERPIECE_LANTERNS => ["<meta name=\"Keywords\" CONTENT=\"Centerpiece battery paper lanterns, LED battery paper lantern centerpiece, Table centerpiece paper lanterns\">\n<meta name=\"Description\" CONTENT=\"Centerpiece LED battery operated paper lanterns are made of quality rice paper with tightly spaced wired ribs. LED WARM-BRIGHT-BURST type bulbs are amazingly bright that lasts over 22 to 36 hours with just one set of batteries.\">"],
			SHOJI_PAPERS => [""],
			FESTIVE_LANTERNS => ["<meta name=\"Keywords\" CONTENT=\"Festive paper lanterns, Festive paper lantern, Preppy Stripe lanterns\">\n<meta name=\"Description\" CONTENT=\Festively designed paperlanterns. Add festive paper lanterns to your summer party fun, event or wedding. Our festive paper lanterns comes in different colors, shapes and printed designs.\>"],
			PAPER_UMBRELLAS => [""],
			VALUE_PACK_LANTERNS => ["<meta name=\"Keywords\" CONTENT=\"paper lanterns, japanese lanterns, asian lanterns.\">\n <meta name=\"Description\" CONTENT=\"Value pack paper lanterns-bulk order at discounted price.\">"],
			BATTERY_LANTERNS => ["<meta name=\"Keywords\" CONTENT=\"Battery operated lanterns, wireless paper lanterns, LED paper lanterns.\">\n<meta name=\"Description\" CONTENT=\"Decorative paper lanterns without cords for outdoor or indoor use. Set on table top as centerpiece or hang paper lanterns on canopies.\">"],
			Contact_Us => ['<meta name="keywords" content="paper lanterns, paper lantern, chinese lanterns, japanese lanterns\"><meta name=\"Description\" CONTENT=\"Sculptured design paper lanterns. Chinese and Japanese paper lanterns handcrafted with bamboo or wired ribbing and high grade rice paper" /><meta name="description" content="Contact Shoji Decor" />'],
			About_Us => ['<meta name="keywords" content="paper lanterns, paper lantern, chinese lanterns, japanese lanterns\"><meta name=\"Description\" CONTENT=\"Sculptured design paper lanterns. Chinese and Japanese paper lanterns handcrafted with bamboo or wired ribbing and high grade rice paper" /><meta name="description" content="About Shoji Decor" />'],
			Policies => ['<meta name="keywords" content="paper lanterns, paper lantern, chinese lanterns, japanese lanterns\"><meta name=\"Description\" CONTENT=\"Sculptured design paper lanterns. Chinese and Japanese paper lanterns handcrafted with bamboo or wired ribbing and high grade rice paper" /><meta name="description" content="Shoji Decor Company Policies" />']
		);
	
@catTitle = split(/\_/, lc($category));

#if($category eq "PAPER_LANTERNS" || $category eq "LANTERN_CORD_KITS" || $category eq "FESTIVE_LANTERNS" || $category eq "PARTY_LANTERNS" || $category eq "BATTERY_LANTERNS")
#{
#	$bulk = "<div class=\"bulk-note\">VOLUME DISCOUNTS- We offer discounts to volume purchases.  Please contact customer service to obtain discounted rates. Toll-free 1-877-746-5438</div>\n";
#}


if(!$category) {
	print $query->redirect('http://shojidecor.com');
} elsif($category eq "About_Us") {
	&print_page_start;
	&print_about_us;
	&print_page_end;
} elsif($category eq "Policies") {
	&print_page_start;
	&print_policies;
	&print_page_end;
} elsif($category eq "Contact_Us") {
	&print_page_start;
	&print_contact_us;
	&print_page_end;
} elsif($category eq "SPECIAL_ORDER") {
	$id = $query->param('id');
	&print_page_start;
	&print_special_order;
	&print_page_end;
} else {
	&print_page_start;
	&set_variables;
	&open_catalog;
	&print_catalog;
	&print_page_end;
}

sub print_page_start {
	print "Content-type: text/html\n\n";
	print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
	print "<html lang=\"en\" xml:lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">\n";
	print "<head>\n";
		print "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />\n";
		print "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\" />\n";
		print "\n";
		print "<!--Style-->\n";
		print "<link href=\"/PShSet/images/style.css\" type=\"text/css\" rel=\"stylesheet\" />\n";
		print "<link href=\"/PShSet/images/favicon.ico\" type=\"image/x-icon\" rel=\"icon\" />\n";
		print "<link href=\"/PShSet/images/favicon.ico\" type=\"image/x-icon\" rel=\"shortcut icon\" />\n";
		print "<link href=\"/PShSet/images/apple-touch-icon.png\" type=\"image/png\" rel=\"apple-touch-icon\" />\n";

                if($detail) {
                    print "<link rel=\"canonical\" href=\"http://www.shojidecor.com/product/$fullcat\" />\n";
                }
                elsif($category eq "About_Us") {
                    print "<link rel=\"canonical\" href=\"http://www.shojidecor.com/about-us\" />\n";
                } elsif($category eq "Policies") {
                    print "<link rel=\"canonical\" href=\"http://www.shojidecor.com/policies\" />\n";
                } elsif($category eq "Contact_Us") {
                    print "<link rel=\"canonical\" href=\"http://www.shojidecor.com/contact-us\" />\n";
                } 
                else {
                    print "<link rel=\"canonical\" href=\"http://www.shojidecor.com/category/$fullcat\" />\n";
                }

		print "<!--Script-->\n";
		print "<script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js\"></script>\n";
		print "<!--Script-->\n";
		print "\n";
		print "<title>" . $Title{$category}[0] . "</title>\n";
		print "$MetaTags{$category}[0]\n";
		print "<meta name=\"verify-v1\" content=\"VKznfaKMZ9b1RyS0jv8O16J2eRxB+5C3uvGe3nHVRyA=\" />\n";
	print "</head>\n";
	print "<body>\n";
		print "<div id=\"container\">\n";
			print "<div id=\"header\">\n";
				print "<div id=\"logo\">\n";
					print "<a href=\"http://shojidecor.com/\" title=\"Home Page\"><img src=\"/PShSet/images/logo.jpg\" alt=\"Shoji Decor - Paper Lanterns for Party and Wedding Decorations\" height=\"112\" width=\"326\" /></a>\n";
				print "</div><!-- END #logo -->\n";
				print "<div id=\"tagline\">\n";
					print "<h2 class=\"tag\"><a href=\"http://shojidecor.com\" title=\"Home Page\">Paper Lanterns<span class=\"gap\">&nbsp;</span>for Party and Wedding Decorations</a></h2>\n";
				print "</div><!-- END #tagline -->\n";
				print "<div id=\"phone\">\n";
					print "<h4>1-877-746-5438</h4>\n";
				print "</div><!-- END #phone -->\n";
				print "<div id=\"miniCart\">\n";
					print "<ul>\n";
						print "<li><a href=\"http://www.shojidecor.com/checkout\" title=\"View Your Shopping Cart\">My Cart</a></li>\n";
						print "<li><a href=\"http://www.shojidecor.com/checkout\" title=\"Proceed To Secure Checkout\" id=\"checkoutLink\">Checkout</a></li>\n";
					print "</ul>\n";
				print "</div><!-- END #miniCart -->\n";
				print "<div id=\"menu\">\n";
					print "<ul id=\"mainMenu\">\n";
						print "<li><a href=\"http://shojidecor.com/\" title=\"Home Page\">Home</a></li>\n";
						print "<li><a href=\"/about-us\" title=\"About Us\">About Us</a></li>\n";
						print "<li><a href=\"/contact-us\" title=\"Contact Us\">Contact Us</a></li>\n";
						print "<li><a href=\"/policies\" title=\"Company Policies\">Policies</a></li>";
						print "<li><a href=\"/sitemap\" title=\"HTML Site Map\">Sitemap</a></li>";
					print "</ul><!-- END #mainMenu -->\n";
					print "<div id=\"search\">\n";
						print "<form action=\"\" method=\"get\">\n";
							print "<input type=\"text\" value=\"Search Site\" id=\"searchBox\" name=\"keyword\" class=\"placeholder\" />\n";
							print "<input type=\"submit\" value=\" \" id=\"searchBtn\" />\n";
						print "</form>\n";
					print "</div><!-- END #search -->\n";
				print "</div><!-- END #menu -->\n";
			print "</div><!-- END #header -->\n";
			print "<div id=\"middle\" class=\"clearfix\">\n";
				print "<div id=\"left\">\n";
					print "<div id=\"categories\" class=\"leftNav\">\n";
						print "<h2>Categories</h2>\n";
						print "<ul>\n";
						open (NAVBAR, "< $nav_file") or die "Can't open $catalog_file";
						@records = <NAVBAR>;
						foreach $record (@records) {
							chomp $record;
							($rec_category) = split (/\t/, $record);
							@catName = split(/\ /, $rec_category);
							$file = join("_", @catName);
							#if($second)
							#{
							#	$file = uc($first) . "_" . uc($second);
							#}
							#else
							#{
							#	$file = uc($first);
							#}
							print "<li><a href=\"/category/" . uc(join("_", @catName)) . "\" title=\"".join(" ", @catName)."\">" . join(" ", @catName) . "</a></li>\n";
						}
						close NAVBAR;

						print "</ul>\n";
					print "</div><!-- END #categories.leftNav -->\n";
					print "<a href=\"http://www.shojidecor.com/category/CLEARANCE_ITEMS\" title=\"View Our Clearance Items\"><img src=\"/PShSet/images/clearance.jpg\" alt=\"View Our Clearance Items\" height=\"149\" width=\"237\" /></a>\n";
				print "</div><!-- END #left -->\n";
				print "<div id=\"content\">\n";
}
sub print_special_order {
	print "<div align=\"left\"><span class=\"toppoint\">SPECIAL&nbsp;ORDER/&nbsp;</span><span class=\"topcurrent\">ITEM # $id</span></div>\n";
	print "<br />\n";
	print "<p class=\"desc\">\n";
	print "<strong>This item requires truck delivery. Please contact us for freight quote. Be sure to provide Item Number, Quantity, and Destination CITY-STATE-ZIP.</strong>\n";
	print "<br /> <a href=\"mailto:shojidecor\@gmail.com\">shojidecor\@gmail.com</a><br>\n";
	print "<br /><strong>Toll free 1-866-482-8264</strong>\n";
	print "</p>\n<p>Thank You!</p>\n";
	print "<br/>\n";
	print "<input class=\"itempad\" type=\"Button\" onclick=\"window.history.back();\" value=\"Return\">\n";
}

sub print_contact_us {
				print "<h1>Contact Us</h1>\n";
				print "<p><strong>If you have any questions or need assistance with your order at shojidecor.com, please contact customer service.  We are here to help:</strong></p>\n";
				print "<p><a href=\"mailto:shojidecor\@gmail.com\">shojidecor\@gmail.com</a></p><br/>\n";
				print "<address<851 Cherry Avenue,#27,box 125 <br />\n";
				print "San Bruno , CA 94066<br />\n";
				print "Tel: 415.242.6197 or Toll Free: 1.877.746.5438<br />\n";
				print "Fax: 650.871.1343</address>\n";
				print "<p>Business Hours: (Monday - Friday)9AM - 6PM pst<br /><a href=\"http://shojidecor.com\"><strong>Shojidecor.com</strong></a></p>\n";
}

sub print_about_us {
				print "<h1>About Us</h1>";
				print "<h2>Mission Statement:</h2><p>Shojidecor.com is dedicated to giving the best service to customers purchasing our paper products so that they may be our customers for life. Our e-store features a variety of products and is designed with simplicity to allow our customers to enjoy the best online shopping experience possible.</p>\n";
}

sub print_policies {
				print "<h1>Company Policies</h1>\n";
				print "<h2>Shipping policy:</h2><p>Orders are usually processed within the next business day. All products are shipped via Federal Express (FedEx). Please note that at this time shojidecor only ships to addresses in the United States. Alaska and Hawaii must be shipped by \"FedEx 2nd Day Air.\"</p>\n";
				print "<h2>Return policy:</h2><p>If you are not satisfied with your purchase, you may return the unused item in its original packaging within 15 days of receipt of your order for a full refund. Shipping & handling charges are not refundable. A 15% restocking fee may apply for large orders or if the returned item is not in its original packaging. Please contact our customer service at 1-877-746-5438 or email us at <a href=\"mailto:shojidecor\@gmail.com\">shojidecor\@gmail.com</a> for return authorization.</p>\n";
				print "<h2>Privacy policy:</h2><p>All information provided are kept strictly confidential at shojidecor.com. We will not sell, trade, or rent your personal information to any third parties.  We use the information you provide about yourself to fulfill your order for our goods and/or services, to respond to your inquiries about your order and to notify you about the status of your order. </p>\n";
				print"<h3>Security:</h3><p><a href=\"http://shojidecor.com\">www.shojidecor.com</a> is sensitive to your concerns regarding the security of using your credit cards and electronic check information to purchase products and services through the Internet. Safeguarding your privacy and confidentiality is of the utmost importance to us.  Our site uses Secure Sockets Layer (SSL) which encrypts your data while it is being transferred over the Internet. This makes it very difficult for someone to steal your credit card information.</p>\n";
}

sub open_catalog {
	eval {
		open (CATALOG, "< $category_file") or die "Can't open $catalog_file";
	};
}

sub print_catalog { 
	@records = <CATALOG>;
	close CATALOG;
			if($detail) {
				&print_detail;
			} else {
				if(!$count) {
					&print_view_all;
				} else {
					&print_products;
				}
			}
				if($detail && $displayDetail[7]) {
					@relatedItem = split(/,/, $displayDetail[7]);
			print "<table cellpadding=0 cellspacing=0 border=0 width=\"100%\">\n";
				print "<tr>\n";
					print "<td class=\"fields\">You may also like<br><br></td>\n";
				print "</tr>\n";
				print "<tr>\n";
					print "<td bgcolor=\"#990000\" height=1><img src=\"http://shojidecor.com/images/spacer.gif\" height=1></td>\n";
					print "<td bgcolor=\"#990000\" height=1 width=20><img src=\"http://shojidecor.com/images/spacer.gif\" width=20 height=1></td>\n";
				print "</tr>\n";
				print "<tr>\n";
					print "<td height=10><img src=\"http://shojidecor.com/images/spacer.gif\" height=10 width=1></td>\n";
				print "</tr>\n";
				print "<tr>\n";
					print "<td>\n";
						print "<table cellpadding=3 cellspacing=0 border=0>\n";
							print "<tr>\n";
							for($index=0; $index <= $#relatedItem; $index++) {
								@displayRelated = split(/-/, $relatedItem[$index]);
								eval {
									open (CATALOG_RE, "< admin/cat_files/$displayRelated[0].txt") or die "Can't open $displayRelated[0].txt";
								};
								@RE_records = <CATALOG_RE>;
								foreach $recor (@RE_records) {
									chomp $recor;
									@displayDat = split (/\t/, $recor);
									if($displayDat[1] eq $displayRelated[1]) {
										$prodname = $displayDat[0];
										$prodprice = $displayDat[4];
									}
								}
								print "<p><a href=\"http://www.shojidecor.com/product/$displayRelated[0]-1-$displayRelated[1]\"><img src=\"http://shojidecor.com/small_image/$displayRelated[1].jpg\"><br>$prodname<br>$prodprice</a></p>\n";
							}
							print"</tr>\n";
						print "</table>\n";
					print "<br /></td>\n";
				print"</tr>\n";
			print "</table>\n";
		}


		
}
sub print_products {
			print "<h1>" . ucfirst(join(" ", @catTitle)) . "</h1>\n";
			for($numberLinks = 0; $numberLinks <= $#records; $numberLinks++) {
				if($numberLinks % $numbItem == 0) {
					if($count == $numbLinks) {
						$Links .= "Page $numbLinks ";
					} else {
						$Links .= "<a href=\"/category/$category-$numbLinks\"> $numbLinks</a>&#160";
					}
					if($numbLinks <= ($#records / $numbItem)) {
						$Links .= "| ";
					}
					$numbLinks++;
				}
			}
			if($#records > 5 && $count) {
				$Links .= "&#160|&#160<a href=\"/category/$category\">All</a>&#160";
			} else {
				$Links .= "&#160|&#160All&#160";
			}
			print "<p>".$Links."</p>\n";
			$formNum = 0;
			for($numbDisplay = $start; $numbDisplay < $end; $numbDisplay++) {
				@product = split (/\t/, $records[$numbDisplay]);
				if(@product) {
					$returnPage = "$category-$count";
					print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"prodTbl\">\n";
						print "<tr>\n";
							print "<td rowspan=\"2\" align=\"center\" width=\"150\"><a href=\"http://www.shojidecor.com/product/$returnPage-$product[1]\"><img src=\"http://shojidecor.com/small_image/$product[1].jpg\" border=0 alt=\"$product[0]\"></a></td>\n";
							print "<td rowspan=\"9\" width=\"10\"><img src=\"http://shojidecor.com/images/spacer.gif\" width=\"10\" /></td>\n";
							print "<td valign=\"top\">\n";
								print "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
									print "<tr>\n";
										print "<td  class=\"prodName\"><a href=\"http://www.shojidecor.com/product/$returnPage-$product[1]\" name=\"$product[0]\">$product[0]</a></td>\n";
									print "</tr>\n";
									print "<tr>\n";
										print "<td height=\"10\"><img src=\"http://shojidecor.com/images/spacer.gif\" /></td>\n";
									print "</tr>\n";
									print "<tr>\n";
										print "<td class=\"content\" valign=\"top\">$product[3]</td>\n";
									print "</tr>\n";
									print "<tr>\n";
										print "<td height=\"30\"><img src=\"http://shojidecor.com/images/spacer.gif\" /></td>\n";
									print "</tr>\n";
									print "</table>\n";
								print "</td>\n";
							print "</tr>\n";
							$numb = 1;
							$availColor = "";
							$options = "";
							for( $index = 8; $index <= $#product; $index++) {
								@option = split(/\;/, $product[$index]);
								$options .= "<option value=\"$product[$index]\">$option[0]</option>\n";
								$numb++;
								$availColor .= $product[$index];
								if($index < $#product) {
									$availColor .= "-";
								}
							}
							print "<tr>\n";
								print "<td>\n";
									print "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n";
										print "<tr>\n";
											print "<td valign=\"bottom\" class=\"content\"><a href=\"http://www.shojidecor.com/product/$returnPage-$product[1]\">More Info</a></td>\n";
										#if($product[8] =~ /^[A-Za-z]/)
										#{
										#	print "<td valign=\"bottom\" class=\"content\"><a href=\"javascript: enlargeImage('Detail', 'http://shojidecor.com/colorChart.html');\">Color Chart</a></td>\n";
										#}
										print "</tr>\n";
									print "</table>\n";
								print "</td>\n";
							print "</tr>\n";
							print "<tr>\n";
								print "<td height=\"20\"><img src=\"http://shojidecor.com/images/spacer.gif\" /></td>\n";
							print "</tr>\n";
							print "<tr>\n";
								print "<td class=\"fields\" align=\"right\">Price: </td>\n";
								print "<td class=\"price\">$product[4]</td>\n";
							print "</tr>\n";
							print "<tr>\n";
								print "<td height=\"20\"><img src=\"http://shojidecor.com/images/spacer.gif\" /></td>\n";
							print "</tr>\n";
							print "<tr>\n";
								print "<td class=\"fields\" align=\"right\">Item #: </td>\n";
								print "<td class=\"content\">$product[1]</td>\n";
							print "</tr>\n";
							print "<tr>\n";
								print "<td height=\"20\"><img src=\"http://shojidecor.com/images/spacer.gif\" /></td>\n";
							print "</tr>\n";
							print "<tr>\n";
								print "<td class=\"fields\" align=\"right\">Available In: </td>\n";
								print "<td class=\"content\">$product[5]</td>\n";
							print "</tr>\n";
							print "<tr>\n";
								print "<td height=\"20\"><img src=\"http://shojidecor.com/images/spacer.gif\" /></td>\n";
							print "</tr>\n";
							print "</table>\n";
						print "</td>\n";
					print "</tr>\n";
	
					#take out dots
					#	print "<tr>\n";
					#		print "<td background=\"http://shojidecor.com/images/dot-00.gif\" height=1><img src=\"http://shojidecor.com/images/spacer.gif\" width=1 height=1></td>\n";
					#	print "</tr>\n";
	
					print "<tr>\n";
						print "<td>\n";
							print "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"#FAF9F8\" width=\"100%\" class=\"btn\">\n";
								print "<tr>\n";
									print "<td height=\"2\" bgcolor=\"#F6F3F0\" colspan=\"4\"><img src=\"http://shojidecor.com/images/spacer.gif\"></td>\n";
								print "</tr>\n";
								print "<tr>\n";
									print "<td width=\"10\" bgcolor=\"#F6F3F0\"><img src=\"http://shojidecor.com/images/spacer.gif\" width=10></td>\n";
									print "<td class=\"content\" colspan=3 bgcolor=\"#F6F3F0\"><b>Please Select</b></td>\n";
								print "</tr>\n";
								print "<tr>\n";
									print "<td height=\"2\" bgcolor=\"#F6F3F0\" colspan=\"4\"><img src=\"http://shojidecor.com/images/spacer.gif\"></td>\n";
								print "</tr>\n";
								print "<tr>\n";
									print "<td height=\"5\" bgcolor=\"#FAF9F8\" colspan=\"4\"><img src=\"http://shojidecor.com/images/spacer.gif\"></td>\n";
								print "</tr>\n";
								print "<form method=\"post\" name=\"$formNum\" action=\"http://shojidecor.com/shopsite_sc/shopping_cart/order.cgi\">\n";# onsubmit=\"return getSKU($formNum, 'http://shojidecor.com/cgi-local/catalog/catalog.pl?category=$category-$count')\">\n";
								print "<tr>\n";
									print "<td align=\"left\">\n";
										#print "<input type=\"hidden\" name=\"upc\" value=\"$product[1]\">\n";
										#print "<input type=\"hidden\" name=\"SKU\" value=\"$product[1]\">\n";
										print "<input type=\"hidden\" name=\"" . $product[2] . ":qnty\" value=\"1\">\n";
										print "<input type=\"hidden\" name=\"storeid\" value=\"*16fc432e618b601917a0a54fc1\">\n";
										print "<input type=\"hidden\" name=\"dbname\" value=\"products\">\n";
										print "<input type=\"hidden\" name=\"function\" value=\"add\">\n";
										print "<input type=\"hidden\" name=\"itemnum\" value=\"$product[2]\">\n";
										print "<input type=\"hidden\" name=\"" . $product[2] . ":finoptnum\" value=1>\n";
		
										print "<select name=\"" . $product[2] . ":finopt:0\" width=150 class=\"option\">\n";
											#$numb = 1;
											#for( $index = 7; $index <= $#product; $index++)
											#{
											#	print "<option value=\"0$numb\">$product[$index]</option>\n";
											#	$numb++;
											#	$availColor += $product[$index];
											#}
											print $options;
										print "</select>\n";
									print "</td>\n";
									print "<td align=\"center\" class=\"arrow\">&#187</td>\n";
									print "<td align=\"center\"><input type=\"image\" src=\"http://shojidecor.com/images/but_add-to-cart.gif\" border=\"0\" /></td>\n";
								print "</tr>\n";
								print "</form>\n";
								print "<tr>\n";
									print "<td height=\"5\" bgcolor=\"#FAF9F8\" colspan=4><img src=\"http://shojidecor.com/images/spacer.gif\" /></td>\n";
								print "</tr>\n";
							print "</table>\n";
							print "<div class=\"btnBorder\"></div>";
						print "</td>\n";
					print "</tr>\n";
					$formNum++;
					}
				}
	
					print "<tr>\n";
						print "<td height=\"1\" bgcolor=\"#000000\"><img src=\"http://shojidecor.com/images/spacer.gif\" height=\"1\" /></td>\n";
					print "</tr>\n";
					print "<tr>\n";
						print "<td height=\"10\"><img src=\"http://shojidecor.com/images/spacer.gif\" /></td>\n";
					print "</tr>\n";
					print "<tr>\n";
						print "<td class=\"content\" align=\"right\">$Links</td>\n";
					print "</tr>\n";
}
sub print_view_all {
					print "<h1>" . ucfirst(join(" ", @catTitle)) . "</h1>\n<p>$catDescription{$category}[0]</p><hr />\n";
					$linkNum = 0;
					#$anchor = 0;
						for($allDisplay = 0; $allDisplay <= $#records; $allDisplay++) {
							if($countLink % $numbItem == 0) {
								$linkNum++;
							}
						$countLink++;
						@product = split (/\t/, $records[$allDisplay]);
					
							print "<div class=\"featProd\">\n";
							print "<a href=\"/product/$category-$linkNum#$product[0]\">$product[0]</a>\n";
							print "<div class=\"featImg\">\n<a href=\"/product/$category-$linkNum#$product[0]\"><img src=\"http://shojidecor.com/thumb_images/$product[1].jpg\"></a>\n</div><!-- END .featImg -->\n";
							print"<div class=\"featCart\">\n";
							print "<div class=\"featPrice\">\n<span>".$product[4]."</span>\n</div><!-- END .featPrice -->\n";
							print "</div><!-- END .featCart -->\n";
							print "</div><!-- END .featProd -->\n";
					if(($allDisplay + 1) % 3 == 0) {
					}
						#if($anchor >= ($numbItem - 1))
						#{
						#	$anchor = 0;
						#}
						#else
						#{
						#	$anchor++;
						#}
					}
}
sub print_detail {
		for($index=0; $index <= $#records; $index++) {
			@tobeDetail = split (/\t/, $records[$index]);
			if($tobeDetail[1] eq $detail) {
				@displayDetail = @tobeDetail;
			}
		}
						print "<h1>" . ucfirst(join(" ", @catTitle)) . "</h1>\n";
						print "<table border=0 cellpadding=0 cellspacing=0>\n";
							print "<tr>\n";
								print "<td align=\"center\"><img src=\"http://shojidecor.com/big_image/$displayDetail[1].jpg\" border=0 alt=\"$displayDetail[0]\"></td>\n";
							print "</tr>\n";
							print "<tr>\n";
								print "<td valign=\"top\">\n";
									print "<table cellpadding=0 cellspacing=0 border=0>\n";
									print "<tr>\n";
										print "<td  class=\"prodName\"><a name=\"$formNum\">$displayDetail[0]</a></td>\n";
									print "</tr>\n";
									print "<tr>\n";
										print "<td height=10><img src=\"http://shojidecor.com/images/spacer.gif\"></td>\n";
									print "</tr>\n";
									print "<tr>\n";
										print "<td class=\"content\" valign=\"top\">$displayDetail[3]</td>\n";
									print "</tr>\n";
									print "<tr>\n";
										print "<td height=10><img src=\"http://shojidecor.com/images/spacer.gif\"></td>\n";
									print "</tr>\n";
									print "</table>\n";
								print "</td>\n";
							print "</tr>\n";
						$numb = 1;
						$availColor = "";
						$options = "";
						for( $index = 8; $index <= $#displayDetail; $index++) {
							@option = split(/\;/, $displayDetail[$index]);
							$options .= "<option value=\"$displayDetail[$index]\">$option[0]</option>\n";
							$numb++;
							$availColor .= $displayDetail[$index];
							if($index < $#displayDetail) {
								$availColor .= "-";
							}
						}
							print "<tr>\n";
								print "<td height=10><img src=\"http://shojidecor.com/images/spacer.gif\"></td>\n";
							print "</tr>\n";
							print "<tr>\n";
								print "<td>\n";
									print "<table cellpadding=0 cellspacing=0 border=0>\n";
										print "<tr>\n";
											print "<td class=\"fields\" align=\"right\">Price: </td>\n";
											print "<td class=\"price\">$displayDetail[4]</td>\n";
										print "</tr>\n";
										print "<tr>\n";
											print "<td height=10><img src=\"http://shojidecor.com/images/spacer.gif\"></td>\n";
										print "</tr>\n";
										print "<tr>\n";
											print "<td class=\"fields\" align=\"right\">Item #: </td>\n";
											print "<td class=\"content\">$displayDetail[1]</td>\n";
										print "</tr>\n";
										print "<tr>\n";
											print "<td height=10><img src=\"http://shojidecor.com/images/spacer.gif\"></td>\n";
										print "</tr>\n";
										print "<tr>\n";
											print "<td class=\"fields\" align=\"right\">Available In: </td>\n";
											print "<td class=\"content\">$displayDetail[5]</td>\n";
										print "</tr>\n";
									print "</table>\n";
								print "</td>\n";
							print "</tr>\n";
							print "<tr>\n";
								print "<td height=20><img src=\"http://shojidecor.com/images/spacer.gif\"></td>\n";
							print "</tr>\n";
						print "</table>\n";
						print "<table cellpadding=0 cellspacing=0 border=0 bgcolor=\"#FAF9F8\" width=\"100%\">\n";
							print "<tr>\n";
								print "<td height=2 bgcolor=\"#F6F3F0\" colspan=4><img src=\"http://shojidecor.com/images/spacer.gif\"></td>\n";
							print "</tr>\n";
							print "<tr>\n";
								print "<td width=10 bgcolor=\"#F6F3F0\"><img src=\"http://shojidecor.com/images/spacer.gif\" width=10></td>\n";
								print "<td class=\"content\" colspan=3 bgcolor=\"#F6F3F0\"><b>Please Select</b></td>\n";
							print "</tr>\n";
							print "<tr>\n";
								print "<td height=2 bgcolor=\"#F6F3F0\" colspan=4><img src=\"http://shojidecor.com/images/spacer.gif\"></td>\n";
							print "</tr>\n";
							print "<tr>\n";
								print "<td height=5 bgcolor=\"#FAF9F8\" colspan=4><img src=\"http://shojidecor.com/images/spacer.gif\"></td>\n";
							print "</tr>\n";
							print "<form method=\"post\" action=\"http://shojidecor.com/shopsite_sc/shopping_cart/order.cgi\">\n";# onsubmit=\"return getSKU($formNum, 'http://shojidecor.com/cgi-local/catalog/catalog.pl?category=$category-$count')\">\n";
							print "<tr>\n";
								print "<td bgcolor=\"#FAF9F8\"><img src=\"http://shojidecor.com/images/spacer.gif\"></td>\n";
								print "<td align=\"left\">\n";
								#print "<input type=\"hidden\" name=\"upc\" value=\"$displayDetail[1]\">\n";
								#print "<input type=\"hidden\" name=\"SKU\" value=\"$displayDetail[1]\">\n";

									print "<input type=\"hidden\" name=\"" . $displayDetail[2] . ":qnty\" value=\"1\">\n";
									print "<input type=\"hidden\" name=\"storeid\" value=\"*16fc432e618b601917a0a54fc1\">\n";
									print "<input type=\"hidden\" name=\"dbname\" value=\"products\">\n";
									print "<input type=\"hidden\" name=\"function\" value=\"add\">\n";
									print "<input type=\"hidden\" name=\"itemnum\" value=\"$displayDetail[2]\">\n";
									print "<input type=\"hidden\" name=\"" . $displayDetail[2] . ":finoptnum\" value=1>\n";
									print "<select name=\"" . $displayDetail[2] . ":finopt:0\" width=150 class=\"option\">\n";
											print $options;
									print "</select>\n";
								print "</td>\n";
								print "<td align=\"center\" class=\"arrow\">&#187</td>\n";
								print "<td align=\"center\"><input type=\"image\" src=\"http://shojidecor.com/images/but_add-to-cart.gif\" border=0></td>\n";
							print "</tr>\n";
							print "</form>\n";
							print "<tr>\n";
								print "<td height=5 bgcolor=\"#FAF9F8\" colspan=4><img src=\"http://shojidecor.com/images/spacer.gif\"><br></td>\n";
							print "</tr>\n";
						print "</table>\n";
						print "<p><br /><a href=\"javascript: history.go(-1)\"><< back</a><br /><br /></p>\n";
}
sub set_variables {
	$view_item = $query->param('item');
}

sub print_home {
	print "<div id=\"splash\">\n";
		print "<img src=\"images/splash.jpg\" alt=\"Nature500 - Quality Vitamins and Supplements!\" height=\"352\" width=\"743\" />\n";
	print "</div><!-- END #splash -->";
	print "<div id=\"welcome\" class=\"clearfix\">\n";
		print "<h1>Welcome to Shoji D&eacute;cor, your source for exquisite party and wedding decorations.</h1>\n";
		print "<p>Our quality and stylish line of chinese paper lanterns, japanese paper lanterns, shoji paper lamps, table lamps, floor lamps, and shoji blinds bring beautiful ambience, and illuminate any party or wedding setting.</p>\n";
	print "</div><!-- END #welcome -->\n";
	print "<div id=\"featured\">\n";
		open (NAVBAR, "< $nav_file") or die "Can't open $catalog_file";
		@records = <NAVBAR>;
		foreach $record (@records) {
			chomp $record;
			($rec_category) = split (/\t/, $record);
			@catName = split(/\ /, $rec_category);
			$file = join("_", @catName);
			#if($second) {
			#	$file = uc($first) . "_" . uc($second);
			#} else {
			#	$file = uc($first);
			#}
			print "<div class=\"featCat\">\n<img src=\"".uc(join("", @catName))."\" alt=\"Value Pack Lanterns\" height=\"140\" width=\"120\" />\n<a href=\"/category/" . uc(join("_", @catName)) . "\" title=".join(" ", @catName).">" . join(" ", @catName) . "</a></div>\n";
			}
		close NAVBAR;
	print "</div><!-- END #featured -->\n";
}

sub print_page_end
{
				print "</div><!-- END #content -->\n";
		print "</div><!-- END #middle -->\n";
		print "<div class=\"push\"></div>\n";
	print "</div><!-- END #container -->\n";
	print "<div id=\"footer\">\n";
		print "<div id=\"foot\">\n";
			print "<div id=\"footMenu\">\n";
				print "<ul>\n";
					print "<li><a href=\"http://shojidecor.com/\" title=\"Home Page\">Home</a></li>\n";
					print "<li>&nbsp;&nbsp;|&nbsp;&nbsp;</li>\n";
					print "<li><a href=\"/contact-us\" title=\"Contact Us\">Contact Us</a></li>\n";
					print "<li>&nbsp;&nbsp;|&nbsp;&nbsp;</li>\n";
					print "<li><a href=\"/about-us\" title=\"About Us\">About Us</a></li>\n";
					print "<li>&nbsp;&nbsp;|&nbsp;&nbsp;</li>\n";
					print "<li><a href=\"/policies\" title=\"Company Policies\">Policies</a></li>";
					print "<li>&nbsp;&nbsp;|&nbsp;&nbsp;</li>";
					print "<li><a href=\"/links.html\" title=\"Important Links\">Links</a></li>";
					print "<li>&nbsp;&nbsp;|&nbsp;&nbsp;</li>";
					print "<li><a href=\"/sitemap\" title=\"HTML Site Map\">Sitemap</a></li>\n";
					print "<li>&nbsp;&nbsp;|&nbsp;&nbsp;</li>\n";
					print "<li><a href=\"http://www.shojidecor.com/checkout\" title=\"Proceed To Secure Checkout\">Checkout</a></li>\n";
				print "</ul>\n";
			print "</div><!-- END #footMenu -->\n";
			print "<div id=\"cc_logos\">\n";
				print "<ul>\n";
					print "<li><img src=\"/PShSet/images/cc_logos.jpg\" alt=\"We Accept: Visa, MasterCard, American Express, and Discover\" height=\"29\" width=\"230\" /></li>\n";
				print "</ul>\n";
			print "</div><!-- END #cc_logos -->\n";
			print "<div id=\"copyright\">\n";
				print "<p>Copyright &copy; 2016 <a href=\"http://shojidecor.com/\" title=\"Home Page\">Shoji D&eacute;cor</a>. All Rights Reserved.</p>\n";
			print "</div><!-- END #copyright -->\n";
			
		print "</div><!-- END #foot -->\n";
	print "</div><!--- END #footer -->\n";
	print "\n\n";
    print "<script type=\"text/javascript\" src=\"/PShSet/images/base.js\"></script>\n";
	print "<script type=\"text/javascript\">\n";
	print "jQuery(document).ready(function(){\n";
	print "jQuery('input[type=\"image\"][src=\"http://shojidecor.com/images/but_add-to-cart.gif\"]').each(function(i){\n";
	print" jQuery(this).attr('src','/PShSet/images/addtocart.png');\n";
	print "});\n";
	print "});\n";
	print "var _gaq = _gaq || [];\n";
	print "_gaq.push(['_setAccount', 'UA-6333470-1']);\n";
	print "_gaq.push(['_trackPageview']);\n";
	print "(function() {\n";
	print "var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n";
	print "ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n";
	print "var s = document.getElementsByTagName('script')[1]; s.parentNode.insertBefore(ga, s);\n";
	print "})();\n";
	print "</script>\n";
print "</body>\n";
print "</html>\n";
}